/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Figuras;

import java.awt.Color;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.TreeMap;
import javax.swing.JFrame;

/**
 *
 * @author Administrador
 */
public class LienzoKL extends Lienzo implements WindowListener, KeyListener{
    protected TreeMap<Integer, Integer> tc= new TreeMap<Integer, Integer>();
    public JFrame jf;
    protected LienzoKL(){
        jf=new JFrame("Ej con Canvas");
        jf.addWindowListener(this);
        jf.setLayout(null);
        jf.setBounds(20,20,450,580);
        jf.setBackground(Color.gray);
        setBounds(20,20,540,540);
        setBackground(Color.DARK_GRAY);
        jf.getContentPane().add(this);
        jf.setVisible(true);

        this.addKeyListener(this);

        tc.put(38, 0); //arriba
        tc.put(40, 1); //abajo
        tc.put(37, 2); //izquierda
        tc.put(39, 3); //derecha
        tc.put(17, 5); //ctrl
        tc.put(18, 6); //Alt
        tc.put(32, 7); //space

    }
        
    protected LienzoKL(String nombre, Integer boundX, Integer boundY){
        jf=new JFrame(nombre);
        jf.addWindowListener(this);
        jf.setLayout(null);
        jf.setBounds(400,100,boundX+30,boundY+50);
        jf.setBackground(Color.gray);
        setBounds(10,10,boundX,boundY);
        setBackground(Color.DARK_GRAY);

        jf.getContentPane().add(this);
        jf.setVisible(true);

        this.addKeyListener(this);

        tc.put(38, 0); //arriba
        tc.put(40, 1); //abajo
        tc.put(37, 2); //izquierda
        tc.put(39, 3); //derecha
        tc.put(17, 5); //ctrl
        tc.put(18, 6); //Alt
        tc.put(32, 7); //space
    }

    public void windowOpened(WindowEvent e) {
       // throw new UnsupportedOperationException("Not supported yet.");
    }

    public void windowClosing(WindowEvent e) {
      // throw new UnsupportedOperationException("Not supported yet.");
        System.exit(0);
    }

    public void windowClosed(WindowEvent e) {
      //  throw new UnsupportedOperationException("Not supported yet.");
        System.exit(0);
    }

    public void windowIconified(WindowEvent e) {
      //  throw new UnsupportedOperationException("Not supported yet.");
    }

    public void windowDeiconified(WindowEvent e) {
    //    throw new UnsupportedOperationException("Not supported yet.");
    }

    public void windowActivated(WindowEvent e) {
      //  throw new UnsupportedOperationException("Not supported yet.");
    }

    public void windowDeactivated(WindowEvent e) {
       // throw new UnsupportedOperationException("Not supported yet.");
    }

    public void keyTyped(KeyEvent e) {}
    public void keyReleased(KeyEvent e) {

    }

    public void keyPressed(KeyEvent e) {

    }

}
